<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\Picture;
class Recommend extends Model
{

    /**
     * 表名称
     * @var $table;
     */
    protected $table = 'recommend';

    /**
     * 主键
     * @var $primaryKey
     */
    protected $primaryKey = 'id';

    /**
     * 时间戳   laravel ORM 自动维护数据库时间戳,用户数据结构的回滚操作,默认开启,我们禁止
     * @var bool $timestamps
     */
    public $timestamps = false;
    protected $appends = array('mobile_picture');

    /**
     * 自动填充字段
     * @var $fillable
     */

    protected $fillable = ['sort_order','recommend_position_id','relation_id','title','subtitle','description','link','sort_order','picture','m_picture'];
    function getMobilePictureAttribute(){

        $picture = $this->getAttribute('m_picture');
        if(!$picture){
            return null;
        }

        return Picture::find($picture)->url;


    }

}
